package com.volokh.danylo.sample_usage.adapter;


import com.ohos.RecyclerContainer;
import com.openharmony.recyclercomponent.ContainerGroup;
import com.volokh.danylo.sample_usage.ResourceTable;
import com.volokh.danylo.utils.Config;
import ohos.agp.components.Component;
import ohos.agp.components.LayoutScatter;
import ohos.app.Context;

import java.util.List;

public class LondonEyeListAdapter extends RecyclerContainer.Adapter {

    private static final boolean SHOW_LOGS = Config.SHOW_LOGS;

    private static final String TAG = LondonEyeListAdapter.class.toString();

    private Context mActivity;

    private  List<String> mList;

    public LondonEyeListAdapter() {
    }

    public LondonEyeListAdapter(Context activity, List<String> list) {
        mActivity = activity;
        mList = list;
    }

    @Override
    public RecyclerContainer.ViewHolder createViewHolder(ContainerGroup parent, int viewType) {
        Component view = LayoutScatter.getInstance(parent.getContext()).parse(ResourceTable.Layout_capsule_layout, parent, false);
        return new PassengerCapsuleViewHolder(view);
    }

    @Override
    public void bindViewHolder(RecyclerContainer.ViewHolder holder, int position) {
        PassengerCapsuleViewHolder viewHolderOriginal = null;
                if (holder instanceof PassengerCapsuleViewHolder) {
                        viewHolderOriginal = (PassengerCapsuleViewHolder) holder;
                    }
                assert viewHolderOriginal != null;
        viewHolderOriginal.mCapsuleName.setText(mList.get(position));
        viewHolderOriginal.mItemView.setTag(mList.get(position));
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }
}
